package com.wl.servlet;

import javax.servlet.ServletContext;
import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

@WebServlet("/app")
public class AppContextServlet extends HttpServlet {

    @Override
    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        ServletContext app = this.getServletContext();
        ServletContext app2 = this.getServletConfig().getServletContext();
        ServletContext app3 = req.getSession().getServletContext();

        System.out.println(app);
        System.out.println(app2);
        System.out.println(app3);

        // 得到web.xml初始化的参数
        System.out.println(app.getInitParameter("version"));
        System.out.println(app.getInitParameter("author"));
    }
}
